home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / usenet / st80_pre4 / Switch3DView.st < prev    next >
Text File  |  1993-07-24  |  4KB  |  111 lines

  1. "    NAME        Switch3DView
  2.     AUTHOR         (Pieter S. van der Meulen)
  3.     FUNCTION    adds a 3D look to SwitchViews
  4.     ST80-VERSIONS    2.3
  5.     PREREQUISITES    
  6.     CONFLICTS 
  7.     DISTRIBUTION      world
  8.     VERSION    ID    1.1
  9.     VERSION DATE    11 Oct 1989
  10.     DATE    11 Oct 1989
  11. "
  12. 'Anybody who attended the OOPSLA89 exhibits may have noticed
  13. that the new fashion in user-interfaces is 3D (depth effects).
  14. I have seen only some effort in Smalltalk80 with respect to 3D.
  15. Even though (I think) that it is not very important to have these
  16. features, users are attracted/amused by them. And, I have even
  17. heard someone saying that Smalltalk has not the most advanced
  18. user-interface anymore (such sacrilege :-) ).
  19. Anyway, I thought it should be really easy to get some of you
  20. Smalltalkers motivated to come up with some examples.
  21. To show how simple this is, I included an example for ParcPlace
  22. Smalltalk-80 V2.3 (but will probably also work for other versions).
  23.  
  24. The Switch3DView, a subclass of SwitchView, adds 3D effects to
  25. Switches. If you want all SwitchViews in the environment (like the
  26. ones in BinaryChoice) to have this behavior, you may use the methods
  27. here as SwitchView methods. In that case, omit the definition and
  28. replace Switch3DView with SwitchView. I do not like MODIFYING
  29. the system classes, so you do it.
  30. Note: the <clearInside> method is really all you need........
  31.  
  32. Try the example <Switch3DView restoreDisplayView controller open>
  33. and have fun,
  34.     Pieter S. van der Meulen.'!
  35.  
  36. SwitchView subclass: #Switch3DView
  37.     instanceVariableNames: ''
  38.     classVariableNames: ''
  39.     poolDictionaries: ''
  40.     category: 'Interface-Menus'!
  41.  
  42. Switch3DView comment:
  43. 'Add 3D effects to Switches.
  44. Try <Switch3DView restoreDisplayView controller open>.
  45. Written by Pieter S. van der Meulen.
  46. '!
  47.  
  48. !Switch3DView methodsFor: 'displaying'!
  49.  
  50. clearInside
  51.     "Create a view with depth effects. Cash a BitBlt for speed.
  52.     Appropriate for most Smalltalk80 versions."
  53.  
  54.     | aRect aBitBlt |
  55.     aRect _ self insetDisplayBox copy.
  56.     aBitBlt _ BitBlt 
  57.         destForm: Display
  58.         sourceForm: nil
  59.         halftoneForm: nil
  60.         combinationRule: Form over
  61.         destOrigin: aRect origin
  62.         sourceOrigin: Display boundingBox origin
  63.         extent: aRect extent
  64.         clipRect: Display boundingBox.
  65.     (label isNil
  66.         ifTrue: [6]
  67.         ifFalse: [((aRect height - label height min:
  68.              (aRect width - label width)) // 2 - 1) min: 10])
  69.             timesRepeat:
  70.                 [aBitBlt destRect: aRect; mask: Form darkGray; copyBits.
  71.                 aRect corner: aRect corner - (1@1).
  72.                 aBitBlt destRect: aRect; mask: Form lightGray; copyBits.
  73.                 aRect origin: aRect origin + (1@1)].
  74.     aBitBlt destRect: aRect; mask: self insideColor; copyBits!
  75.  
  76. highlight
  77.     "Keep the switches de-emphasized appearance close to its
  78.     emphasized appearance. Only appropriate for ParcPlace Smalltalk."
  79.  
  80.     highlightForm == nil ifFalse: [^highlightForm
  81.             displayOn: Display
  82.             at: self displayBox topLeft
  83.             clippingBox: self insetDisplayBox
  84.             rule: Form reverse
  85.             mask: nil].
  86.     emphasisOn
  87.         ifTrue: [Display reverse: (self insetDisplayBox insetBy: 1)]
  88.         ifFalse: 
  89.             ["Display reverse: (self insetDisplayBox insetBy: 1)."
  90.             Display reverse: (self insetDisplayBox insetBy: 2)]! !
  91.  
  92. !Switch3DView class methodsFor: 'examples'!
  93.  
  94. restoreDisplayView
  95.     "To create a Switch which allows you to restore the display,
  96.     execute : "
  97.         "Switch3DView restoreDisplayView controller open"
  98.  
  99.     | topView aSwitch aView |
  100.     topView _ StandardSystemView new.
  101.     topView minimumSize: 128@40.
  102.     topView maximumSize: 128@40.
  103.     aSwitch _ Switch newOn.    
  104.     aSwitch onAction: [ScheduledControllers restore].            
  105.     "aSwitch offAction: [ScheduledControllers restore]."            
  106.     aView _ self new model: aSwitch.
  107.     aView borderWidth: 1; label: 'Restore display' asDisplayText.
  108.     topView addSubView: aView.
  109.     ^topView! !
  110.  
  111.